<template>
	<view v-if="empty===true||empty==='true'" @touchmove.stop.prevent="stopPrevent" :class="{freeH:positions!='fixed'}" :style="{ zIndex: zIndexs,top:top+'rpx',position:positions }" class="empty flex flex-direction align-center">
		<image :src="imgUrl" :class="{img:btnSource}" class="mimage" lazy-load mode="aspectFit" :style="{marginTop:imgMargin}"></image>
		<view class="empty-tips">
			<view class="text-lg">{{content}}</view>
			<view v-if="showBtn" class="navigator" @click="navToPge(pageUrl,navType)">{{btnText}}</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {};
		},
		props: {
			// 是否为首页定位
			// isFromeLocation: {
			// 	type: Boolean,
			// 	default: false
			// },
			// 是否扫码
			// isRecalculation: {
			// 	type: Boolean,
			// 	default: false
			// },
			//是否自定义按钮
			btnSource:{
				type: Boolean,
				default: false
			},
			// 是否显示空置页
			empty: {
				type: Boolean,
				default: false
			},
			// 是否显示按钮
			showBtn: {
				type: Boolean,
				default: false
			},
			// 图片地址
			imgUrl: {
				type: String,
				default: '../../static/empty.png'
			},
			// 页面描述文字内容
			content: {
				type: String,
				default: '暂无数据'
			},
			btnText:{
				type: String,
				default: '去逛逛'
			},
		  imgMargin:{
				type: String,
				default: '0rpx'
			},
			//按钮文字内容
			textContent: {
				type: String,
				default: '去逛逛'
			},
			// 目标页跳转链接地址
			pageUrl: {
				type: String,
				default: '/index/home/home'
			},
			// 跳转类型(默认跳转tabbar页面)
			navType: {
				type: String,
				default: 'switchTab'
			},
			zIndexs:{
				type:Number,
				default:998
			},
			top:{
				type:Number,
				default:0
			},
			positions:{
				type: String,
				default: 'fixed'
			},

		},
		methods: {
			navToPge(url, type) {
				// console.log('type---------',type)
				if (type === 'switchTab') {
					this.switchTab(url)
				}else if(type==='back'){
					uni.navigateBack()
				}else {
					this.navigateTo(url);
				}
			},
			toHomePage(){
				uni.switchTab({url:'/pages/index/home/home'})
			},
			tapBtnAct(){
				this.$emit('btnAction');
			},
			stopPrevent() {},

		}
	}
</script>

<style lang="scss">
	.empty {
		// position: fixed;
		left: 0;
		top: 0;
		background: #fff;
		width: 100%;
		height: 100%;
		min-height: 100vh;
		// padding-bottom: 340rpx;
		display: flex;
		justify-content: center;
		flex-direction: column;
		align-items: center;
		text-align: center;
		// z-index: 9999;
		&.freeH{
			min-height: 100%;
		}
		.mimage {
			width: 332rpx;
			height: 215rpx;
		}
		.img{
			width: 320rpx;
			height: 300rpx;
		}
		.empty-tips {
			text-align: center;
			margin-top: 35rpx;
			color: #999;
			font-size: 28rpx;

			.tip {
				margin-top: 12rpx;
			}

			.navigator {
				display: inline-block;
				margin-top: 40rpx;
				min-width: 150rpx;
				height: 55rpx;
				line-height: 55rpx;
				font-size: 32rpx;
				background: $view-act;
				color: #fff;
				border-radius: 4rpx;
				padding: 0 10rpx;
			}
			.selfBtn{
				display: inline-block;
				margin-top: 40rpx;
				min-width: 182rpx;
				height: 50rpx;
				line-height: 50rpx;
				font-size: 26rpx;
				background: $view-act;
				color: #fff;
				border-radius: 25rpx;
				padding: 0 10rpx;
			}
			.locationBtn {
				display: inline-block;
				margin-top: 40rpx;
				min-width: 180rpx;
				height: 55rpx;
				line-height: 55rpx;
				font-size: 24rpx;
				background: $view-act;
				color: #fff;
				border-radius: 4rpx;
				padding: 0 10rpx;

				&.slect {
					margin-top: 30rpx;
					background: #fff;
					color: #666;

					&::after {
						border-radius: 8rpx;
					}
				}
			}
		}

	}
</style>
